<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/component/pear/css/pear.css" />
</head>
<body>
<form class="layui-form">
    <div class="mainBox">
        <div class="main-container">
            <br>
            <br>

            <div class="layui-form-item">
                <label class="layui-form-label">易支付网关</label>
                <div class="layui-input-block" style="max-width: 800px;">
                    <input type="text" name="api_gateway" value="{$option.api_gateway}" required  lay-verify="required" autocomplete="off" class="layui-input">
                    <div class="layui-form-mid layui-word-aux">
                        例子：http://www.eshanpay.com/submit.php
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">易支付商户</label>
                <div class="layui-input-block" style="max-width: 800px;">
                    <input type="text" name="api_pid" value="{$option.api_pid}" required  lay-verify="required" autocomplete="off" class="layui-input">
                    <div class="layui-form-mid layui-word-aux">
                        请填写易支付的商户ID
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">易支付密钥</label>
                <div class="layui-input-block" style="max-width: 800px;">
                    <input type="text" name="api_key" value="{$option.api_key}" required  lay-verify="required" autocomplete="off" class="layui-input">
                    <div class="layui-form-mid layui-word-aux">
                        请填写易支付的商户密钥
                    </div>
                </div>
            </div>


            <br>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="save">保存设置</button>
                </div>
            </div>

        </div>
    </div>
</form>
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<script>
    layui.use(['form','jquery'],function(){
        let form = layui.form;
        let $ = layui.jquery;

        form.on('submit(save)', function(data){
            $.ajax({
                data:JSON.stringify(data.field),
                dataType:'json',
                contentType:'application/json',
                type:'post',
                success:function(res){
                    //判断有没有权限
                    if(res && res.code == 999){
                        layer.msg(res.msg, {
                            icon: 5,
                            time: 2000,
                        })
                        return false;
                    }else if(res.code == 200){
                        layer.msg(res.msg,{icon:1,time:1000},function(){
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        });
                    }else{
                        layer.msg(res.msg,{icon:2,time:1000});
                    }
                }
            })
            return false;
        });
    })
</script>
</body>
</html>